var stepId = $CertusJsonAjax.getStepInstanceId();
var processId = $CertusJsonAjax.getProInstanceId();
$CertusFormAjax.ajax('findWaitInfo',{"processId":processId},function (response) {
    var data = response.data.appInfo;
    $$scope.id = data.id;
    $$scope.tripNum = data.trip_num;
    $$scope.userName = data.user_name;
    $$scope.planStime = data.trip_star_time;
    $$scope.planEtime = data.trip_end_time;
    $$scope.deptName = data.department_name;
    var bugetInfo = response.data.bugetInfo;
    $$scope.spMoney = 0;
    $$scope.wspMoney = 0;
    for (var i=0;i<bugetInfo.length;i++){
        if (bugetInfo[i].status==1){
            $$scope.spMoney = bugetInfo[i].buget;
        }else {
            $$scope.wspMoney = bugetInfo[i].buget;
        }
    }
    if(data.type==1){
        $$scope.type ="出差";
    }else{
        $$scope.type ="公干";
    }
});

//查询审批人职位
$CertusFormAjax.ajax('getSpPosition',{},function (response) {
    var data = response.data;
    $$scope.position = data;
});
$CertusFormAjax.ajax('findCCWaitInfo',{"processId":processId},function (response) {
    var data = response.data;
    var plans = [];
    for (var i=0;i<data.length;i++){
        if (data[i].proPlans[0].planResult==0){
            data[i].proPlans[0].planResult="待审批";
        }else if (data[i].proPlans[0].planResult==1){
            data[i].proPlans[0].planResult="审批中";
        }else if (data[i].proPlans[0].planResult==2){
            data[i].proPlans[0].planResult="退回";
        }else if (data[i].proPlans[0].planResult==3){
            data[i].proPlans[0].planResult="不同意";
        }else if (data[i].proPlans[0].planResult==4){
            data[i].proPlans[0].planResult="审批通过";
        }else if (data[i].proPlans[0].planResult==5){
            data[i].proPlans[0].planResult="主动取消";
        }else{
            data[i].proPlans[0].planResult="出差结果审批通过";
        }
        data[i].proPlans[0].bugetsl = data[i].bugets;
        data[i].proPlans[0].stUserName = data[i].stUserName;
        plans.push(data[i].proPlans[0])
    }
    $$scope.plans = plans;
});

//取消申请
$(".down").on('click',function () {
    $CertusFormAjax.ajax('shutdownWait',{"id":$$scope.id,"stepId":stepId,"processId":processId},function (response) {
        layer.msg("取消成功！");
        window.history.back();
    })
});
//提交申请
$(".agree").on('click',function () {
    $CertusFormAjax.ajax('agreeTrip',{"id":$$scope.id,"stepId":stepId,"processId":processId},function (response) {
        layer.msg("审批成功！");
        window.history.back();
    })
})